package com.xzit.xzitexprement2.Controller;

import com.xzit.xzitexprement2.Pojo.courses;
import com.xzit.xzitexprement2.Pojo.result;
import com.xzit.xzitexprement2.Service.coursesService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/courses")
public class coursesController {
    @Autowired
    private coursesService coursesservice;
    @GetMapping("/listAll")
    public result listAll(){
        return result.success(coursesservice.listAll());
    }
    @GetMapping("/getById/{cid}")
    public result getById(@PathVariable Integer cid){
        return result.success(coursesservice.getById(cid));
    }
    @PostMapping("/add")
    public result add(@RequestBody courses Courses){
        coursesservice.add(Courses);
        return result.success();
    }
}
